﻿using System.Collections.Generic;

namespace SysDataSource
{
    internal static class DataSourceFactory
    {
        private static readonly object Lock = new object();
        private static IDictionary<string, ISysDS> _services;

        public static ISysDS GetService(string dataType)
        {
#if DEBUG
            _services = null;
#endif
            if (_services == null)
            {
                lock (Lock)
                {
                    if (_services == null)
                    {
                        _services = new Dictionary<string, ISysDS>
                                        {
                                            {"config", new ConfigDS()},
                                            {"sysconfig", new ConfigDS()}
                                        };
                    }
                }
            }
            var key = dataType.ToLower();
            if (_services.ContainsKey(key))
                return _services[key];
            return null;
        }
    }
}
